from django.db import models
from django.utils import timezone

# 基类
class Base(models.Model):
    # 创建时间
    create_time = models.DateTimeField(default=timezone.now, null=True)
    # 允许继承
    class Meta:
        abstract = True

# 用户表
class User(Base):
    # 用户名
    username = models.CharField(max_length=100)
    # 密码
    password = models.CharField(max_length=100)

    class Meta:
        db_table = 'user'

# 产品表
class Goods(Base):
    name = models.CharField(max_length=200)

    desc = models.CharField(max_length=200, null=True)

    img = models.CharField(max_length=200, null=True)

    price = models.IntegerField()

    class Meta:
        db_table = 'goods'

# 订单表
class Cart(Base):
    cnum = models.IntegerField(null=True)
    
    uid = models.IntegerField(null=True)
	
    gid = models.IntegerField(null=True)

	# 声明表名
    class Meta:
        db_table = "cart"

# 订单详情
class Comment(Base):
	uid = models.IntegerField(null=True)

	content = models.CharField(max_length=400)
    
	gid = models.IntegerField(null=True)

	# 声明表名
	class Meta:
		db_table = "comment"


